package com.gw.detail.controllor.detail;

import com.gw.detail.domain.Innen;
import com.gw.detail.service.IInnenService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆内部零部件损坏Controller
 *
 * @author WangBin
 * @date 2021-04-30
 */
@RestController
@RequestMapping("/detail/innen")
public class InnenController extends BaseController {
    @Autowired
    private IInnenService innenService;

    /**
     * 查询车辆内部零部件损坏列表
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:list')")
    @GetMapping("/list")
    public TableDataInfo list(Innen innen) {
        startPage();
        List<Innen> list = innenService.selectInnenList(innen);
        return getDataTable(list);
    }

    /**
     * 导出车辆内部零部件损坏列表
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:export')")
    @Log(title = "车辆内部零部件损坏", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Innen innen) {
        List<Innen> list = innenService.selectInnenList(innen);
        ExcelUtil<Innen> util = new ExcelUtil<Innen>(Innen.class);
        return util.exportExcel(list, "车辆内部零部件损坏数据");
    }

    /**
     * 获取车辆内部零部件损坏详细信息
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(innenService.selectInnenById(id));
    }

    /**
     * 新增车辆内部零部件损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:add')")
    @Log(title = "车辆内部零部件损坏", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Innen innen) {
        return toAjax(innenService.insertInnen(innen));
    }

    /**
     * 修改车辆内部零部件损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:edit')")
    @Log(title = "车辆内部零部件损坏", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Innen innen) {
        return toAjax(innenService.updateInnen(innen));
    }

    /**
     * 删除车辆内部零部件损坏
     */
    @PreAuthorize("@ss.hasPermi('detail:innen:remove')")
    @Log(title = "车辆内部零部件损坏", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(innenService.deleteInnenByIds(ids));
    }
}
